package com.itheima.leetcode.od.c.logicalsimulation;

import java.util.Scanner;

/**
 * <h3>分割均衡字符串</h3>
 */
public class SplitBalancedString {
    public static void main(String[] args) {
        //处理输入
        Scanner in = new Scanner(System.in);
        String tmp1 = in.nextLine();
        System.out.print(balancedStringSplit(tmp1));
    }

    public static int balancedStringSplit(String s) {
        int num = 0;
        int res = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == 'X') {
                num++;
            } else {
                num--;
            }

            if (num == 0) {
                res++;
            }
        }
        return res;
    }
}